Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix next session times #67

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

stucharo
Copy link

@stucharo stucharo commented Aug 7, 2020

This addresses issue #24.

Changes are:

  • Check added to next_session_times() to catch seasons with no upcoming events;
  • Implemented RaceWeekCars subclass in NextSessionTimes;
  • Adds list comprehension to NextSessionTimes.race_week_cars to generate new objects.

@@ -174,3 +175,11 @@ def __init__(self, data):
self.wind_speed_value = data['4']
# Used outside of d dict; Holds refresh time of data
# self.reloadtime = dict['18']

class RaceWeekCars:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason for this class to be a part of the NextSessionTimes class, we may end up using it again if we find an endpoint that returns raceweekcars.

Also, we have one or two more, similar Car classes, is there potential for code reuse there? I know i have seen some type of car with an id and a max dry tire sets and so on before, so lets make sure we aren't repeating code just in case.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@XanderRiga Isn't this nested class in line with how we have the other classes setup?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cases where we did that we were extending another Car and it was a type of car that we would never see anywhere else because they sent different data. I am not super sure that is the case here since they specifically refer to it as raceWeekCars, which to me implies this is a specific type of car that is a race week car, which I believe could be reused.

That being said, if we want to keep it as a class inside the other class it's fine, but we should at least be doing the extending of the base car and only adding the specific fields that don't exist in the base class here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The race_week_cars is an attribute of NextSessionTimes and RaceGuide.Schedule.Race so I agree that it doesn't make sense to subclass with NextSessionTimes. Also RaceWeekCars is a bit ambiguous since whilst it does list the car id for that session, it's more about some session specific attributes for those cars, which aren't really logical attributes of any other Car classes.

So logically it might sit better as a subclass of Race, but that makes it difficult to access from NextSessionTimes. Leaving it as a standalone class feels like the best place to define it and make it accessible to every object that needs access.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants